package com.example.chat.view

import android.content.res.Configuration
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.ui.unit.dp
import com.example.featuresdk.view.ScreenConstraints

class LayoutConstraints: ScreenConstraints() {
    /*List Constraints*/
    val defaultTextFieldWidthDp
        get() = screenWithDp - 34 * 3 - 12

    val activeTextFieldWidthDp
        get() = screenWithDp - 34 * 4 - 12

    val defaultChatWindowHeightDp
        get() = appBodyHeightDp

    val activeChatWindowHeightDp
        get() = appBodyHeightDp - softKeyboardHeightDp

    val userIconWidth = 50
    val messageContentWidth
        get() = screenWithDp - userIconWidth - userIconWidth

    val smallEmojiSizeDp: Int = 50
    val mediumEmojiSizeDp: Int = 70
    val largeEmojiSizeDp: Int = 80
    val emojiPaddingValues: PaddingValues = PaddingValues(8.dp)
    val dashboardPaddingValues: PaddingValues = PaddingValues(3.dp,6.dp,3.dp,1.dp)

    /*Topic entry constraints*/
    val horizontalPaddingDp: Int = 4
    val spacerWidthDp: Int = 8
    val tailingContentWidthDp: Int = 70
    val topicEntryRowHeightDp: Int = 50
    val topicTitleHeightDp: Int = 30

    val topicSummaryHeightDp = topicEntryRowHeightDp - topicTitleHeightDp

    val topicTitleWidthDp
        get() = screenWithDp - horizontalPaddingDp - spacerWidthDp - topicEntryRowHeightDp - spacerWidthDp - tailingContentWidthDp

    val bottomLineWidthDp
        get() = topicTitleWidthDp + tailingContentWidthDp

    companion object{
        val instance = LayoutConstraints()

        fun init(configuration: Configuration): LayoutConstraints{
            synchronized(instance) {
                if (configuration.screenWidthDp != instance.screenWithDp) {
                    instance.init(configuration)
                }
            }
            return instance
        }
    }
}